package com.clever.mall.controller;

import com.clever.mall.commons.dto.RefundDto;
import com.clever.mall.commons.result.BaseResult;
import com.clever.mall.service.RefundService;
import com.clever.mall.vo.RefundVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.Max;
import java.util.List;

/**
 * @program: project-item
 * @author: hzx
 * @since: JDK 1.8
 * @create: 2020-11-12 10:12
 **/
@RestController
@RequestMapping("/refund")
public class RefundController {

    @Resource
    RefundService service;

    /**
     * 添加
     * @param refundDto
     * @return
     */
    @PostMapping("/add")
    public BaseResult<Integer> addRefund(@RequestBody RefundDto refundDto) {
        return BaseResult.success(service.insertRefund(refundDto));
    }

    /**
     * 查询所有退款信息
     * @param uid
     * @return
     */
    @GetMapping("/getAll")
    public BaseResult<List<RefundVo>> getRefundAll(int uid) {
        return BaseResult.success(service.selectRefundAll(uid));
    }

    /**
     * 通过id查询
     * @param rid
     * @return
     */
    @GetMapping("/getId")
    public BaseResult<RefundVo> getRefund(int rid) {
        return BaseResult.success(service.selectRefundById(rid));
    }

    /**
     * 修改退款状态（必要数据：订单id(orderId)、退款状态(refundStatus)）
     * @param refundDto
     * @return
     */
    @PostMapping("/updRefundStatus")
    public BaseResult<Integer> updateRefundStatus(@RequestBody RefundDto refundDto) {
        return BaseResult.success(service.updateRefundStatus(refundDto));
    }

}
